package slidingWindows;

public class minLenshuzu {
    public int minSubArrayLen(int target, int[] nums) {
        int n=nums.length;
        int left=0;
        int right=0;
        int min=n+1;
        int sum=0;
        for(right=0;right<n;right++){
            sum+=nums[right];
            while(sum>=target){
                min=Math.min(min,right-left+1);
                sum-=nums[left++];
            }
        }
        if(min==n+1){
            return 0;
        }
        return min;
    }
}
